package com.yuda.operationcenter.domain;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.yuda.common.core.annotation.Excel;
import com.yuda.common.core.web.domain.BaseEntity;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * 资讯对象 oper_information
 *
 * @author wyn
 * @date 2021-04-12
 */
public class OperInformation extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * $column.columnComment
     */
    private Long id;

    /**
     * 标题
     */
    @Excel(name = "标题")
    private String title;

    /**
     * 外键，引文了标签表的主键
     */
    @Excel(name = "外键，引文了标签表的主键")
    private Long labelId;

    /**
     * 内容类型，0: url  1:富文本内容
     */
    @Excel(name = "内容类型，0: url  1:富文本内容")
    private Integer contentType;

    /**
     * 内容 如果 content_type 是0 ，则此处是url,如果content_type是1 则此内容是 富文本编辑器里的值
     */
    @Excel(name = "内容 如果 content_type 是0 ，则此处是url,如果content_type是1 则此内容是 富文本编辑器里的值")
    private String content;

    /**
     * 展示开始时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "展示开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date showBeginTime;

    /**
     * 展示结束时间
     */
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "展示结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date showEndTime;

    /**
     * 排序值
     */
    @Excel(name = "排序值")
    private Integer orderNo;

    /**
     * 封面的url
     */
    @Excel(name = "封面的url")
    private String cover;

    @Excel(name = "摘要")
    private String summary;

    /**
     * 0下架 1上架
     */
    @Excel(name = "0下架 1上架 2 待上架")
    private Integer onSell;

    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date publishTime;

    private String labelName;

    /**
     * 请求参数
     */
    private String param;


    public String getLabelName() {
        return labelName;
    }

    public void setLabelName(String labelName) {
        this.labelName = labelName;
    }

    private Integer hitCounts;

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public Long getLabelId() {
        return labelId;
    }

    public void setLabelId(Long labelId) {
        this.labelId = labelId;
    }

    public void setContentType(Integer contentType) {
        this.contentType = contentType;
    }

    public Integer getContentType() {
        return contentType;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getContent() {
        return content;
    }

    public void setShowBeginTime(Date showBeginTime) {
        this.showBeginTime = showBeginTime;
    }

    public Date getShowBeginTime() {
        return showBeginTime;
    }

    public void setShowEndTime(Date showEndTime) {
        this.showEndTime = showEndTime;
    }

    public Date getShowEndTime() {
        return showEndTime;
    }


    public Integer getOrderNo() {
        return orderNo;
    }

    public void setCover(String cover) {
        this.cover = cover;
    }

    public String getCover() {
        return cover;
    }

    public void setOnSell(Integer onSell) {
        this.onSell = onSell;
    }

    public Integer getOnSell() {
        return onSell;
    }

    public String getSummary() {
        return summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public Date getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(Date publishTime) {
        this.publishTime = publishTime;
    }

    public Integer getHitCounts() {
        return hitCounts;
    }

    public void setHitCounts(Integer hitCounts) {
        this.hitCounts = hitCounts;
    }


    public void setOrderNo(Integer orderNo) {
        this.orderNo = orderNo;
    }

    @Override
    public Map<String, Object> getParams() {
        Map map = JSON.parseObject(this.param, Map.class);
        if(map !=null) {
            String onSell = (String) map.get("onSell");
            if (onSell != null) {
                map.put("onSell", onSell.split(","));
            }
        }
        return map;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public String getParam() {
        return param;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("title", getTitle())
                .append("labelId", getLabelId())
                .append("contentType", getContentType())
                .append("content", getContent())
                .append("showBeginTime", getShowBeginTime())
                .append("showEndTime", getShowEndTime())
                .append("orderNo", getOrderNo())
                .append("cover", getCover())
                .append("onSell", getOnSell())
                .append("createTime", getCreateTime())
                .append("updateTime", getUpdateTime())
                .toString();
    }
}
